﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nido.Common.BackEnd;
using System.IO;

namespace Nido.Transport.Web.Common
{
    public class TransportSecutiryTocken
    { }

    public class PermissionDenySession
    {
        public string Message { get; set; }
        public string SettingMessage { get; set; }
        public void Load(string name)
        { Message = "You don't have permission to access " + name + " page."; }
        public void SetSettingMessage(string time)
        { SettingMessage = "Not Allow to put Requisitions after" + time; }
    }

    public class TransportSession
    {
        public int EmployeeId { get; set; }
        public int DepartmentId { get; set; }
        public int PlantId { get; set; }
        public int SubUnitId { get; set; }
        public int TransportDivisionId { get; set; }
        public string EmployeeImageUrl { get; set; }
        public TransportSecutiryTocken ActiveSecurityTocken { get; set; }
        //public GenericResponse<IEnumerable<PermissionTaskAllocation>> Permission { get; set; }
        //public GenericResponse<IEnumerable<SettingAllocation>> SystemSetting { get; set; }

        //public List<PermissionTaskAllocation> Global { get; set; }
        //public List<PermissionTaskAllocation> Division { get; set; }
        //public List<PermissionTaskAllocation> Plant { get; set; }
        //public List<PermissionTaskAllocation> Team { get; set; }

        //public bool CheckEmployeeIsActive(string userId)
        //{
        //    EmployeeHandler employeeHandler = new EmployeeHandler();
        //    GenericResponse<IEnumerable<Employee>> reponse = employeeHandler.GetAllGeneric(x => x.UserId.ToLower().Trim() == userId.ToLower().Trim() && x.IsActive==1);
        //    if (reponse.Successful)
        //    {
        //        if (reponse.Result.Count() ==1)
        //            return true;
        //        else
        //            return false;
        //    }
        //    else
        //        return false;
        //}

        //public bool Load(string userId, int transportDivisionId)
        //{
        //    EmployeeHandler employeeHandler = new EmployeeHandler();
        //    PermissionTaskAllocationHandler permissionTaskAllocationHandler = new PermissionTaskAllocationHandler();
        //    SettingAllocationHandler settingAllocationHandler = new SettingAllocationHandler();


        //    GenericResponse<Employee> employeeReponse = employeeHandler.GetDeepEmployee(x => x.UserId.ToLower().Trim() == userId.ToLower().Trim());
        //    if (employeeReponse.Successful)
        //    {
        //        Nido.Transport.Bll.Models.Employee employee = employeeReponse.Result;
        //        EmployeeId = employee.EmployeeId;
        //        DepartmentId = employee.SubUnit.Team.Department.DepartmentId;
        //        PlantId = employee.SubUnit.Team.Department.Plant.PlantId;
        //        SubUnitId = employee.SubUnitId;
        //        TransportDivisionId = transportDivisionId;
        //        EmployeeImageUrl = Path.Combine(ConstValues.IMAGEDIRECTORY, employee.EPFNo.Trim() + ".jpg");
        //        GenericResponse<IEnumerable<PermissionTaskAllocation>> permissionResponse = permissionTaskAllocationHandler
        //                                                                                                            .Include("TransportDevision")
        //                                                                                                            .Include("Team")
        //                                                                                                            .Include("Plant")
        //                                                                                                            .Include("PermissionTask.PermissionType")
        //                                                                                                            .Include("Employee.Grade")
        //                                                                                                            .GetAllGeneric(x => x.EmployeeId == EmployeeId);
        //        if (permissionResponse.Successful)
        //        {
        //            Permission = permissionResponse;

        //            GenericResponse<IEnumerable<Nido.Transport.Bll.Models.SettingAllocation>> SettingResponse = settingAllocationHandler
        //                                                                                            .Include("SettignLevel")
        //                                                                                            .Include("Setting")
        //                                                                                            .Include("Plant")
        //                                                                                            .Include("TransportDevision")
        //                                                                                            .GetAllGeneric(x => x.PlantId == PlantId || x.TransportDevisionId == transportDivisionId);
        //            if (SettingResponse.Successful)
        //            {
        //                SystemSetting = SettingResponse;
        //                return true;
        //            }
        //            else
        //                return false;
        //        }
        //        else
        //            return false;
        //    }
        //    else
        //        return false;
        //}
    }
}